package org.example.day;

import org.example.linkedlist.ListNode;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/06/20 21:52
 */
public class Solution160 {

    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        if(headA == null || headB == null){
            return null;
        }
        ListNode pA = headA, pB = headB;
        while (pA != pB){
            pA = pA == null ? headB : pA.next;
            pB = pB == null ? headA : pB.next;
        }
        return pA;
    }

}
